import axios from "axios";


export async function showAll(page,limit){
    var resp = await axios.get("/api/petsSystem/petowners.do",{
        params:{
            method:"pageTable",
            page,
            limit
        }
    });
    console.log(resp);
    return resp.data;
}
export async function showAllPet(page,limit,id){
    var resp = await axios.get("/api/petsSystem/pets.do",{
        params:{
            method:"pageTable",
            page,
            limit,
            id
        }
    });
    console.log(resp);
    return resp.data;
}

export async function addOwner(Owner){
    var resp = await axios.get("/api/petsSystem/petowners.do",{
        params:{
            method:"add",
            ownerNickname:Owner.ownerNickname,
            ownerName:Owner.ownerName,
            ownerHeadpic:Owner.ownerHeadpic,
            ownerAddress:Owner.ownerAddress,
            ownerRegion:Owner.ownerRegion,
            ownerScore:Owner.ownerScore,

        }
    });
    console.log(resp);
    return resp.data;
}

export async function addPet(Pet){
    var resp = await axios.get("/api/petsSystem/pets.do",{
        params:{
            method:"add",
            petName:Pet.petName,
            petRace:Pet.petRace,
            petColor:Pet.petColor,
            petBirthday:Pet.petBirthday,
            petTemper:Pet.petTemper,
            petType:Pet.petType,
            fkOwnerId:Pet.fkOwnerId,

        }
    });
    console.log(resp);
    return resp.data;
}

export async function updatePet(Pet){
    var resp = await axios.get("/api/petsSystem/pets.do",{
        params:{
            method:"update",
            petId:Pet.petId,
            petName:Pet.petName,
            petRace:Pet.petRace,
            petColor:Pet.petColor,
            petBirthday:Pet.petBirthday,
            petTemper:Pet.petTemper,
            petType:Pet.petType,
        }
    });
    return resp.data;
}

export async function updateOwner(Owner){
    var resp = await axios.get("/api/petsSystem/petowners.do",{
        params:{
            method:"update",
            ownerId:Owner.ownerId,
            ownerNickname:Owner.ownerNickname,
            ownerName:Owner.ownerName,
            ownerHeadpic:Owner.ownerHeadpic,
            ownerAddress:Owner.ownerAddress,
            ownerRegion:Owner.ownerRegion,
            ownerScore:Owner.ownerScore,

        }
    });
    console.log(resp);
    return resp.data;
}

export async function deleteOwner(id){
    var resp = await axios.get("/api/petsSystem/petowners.do",{
        params:{
            method:"delete",
            ownerId:id
        }
    });
    return resp.data;
}


export async function deletePet(id){
    var resp = await axios.get("/api/petsSystem/pets.do",{
        params:{
            method:"delete",
            petId:id
        }
    });
    return resp.data;
}

export async function query(type,content,page,limit){
    var resp = await axios.get("/api/petsSystem/petowners.do",{
        params:{
            method:"query",
            type,
            content,
            page,
            limit
        }
    });
    return resp.data;
}

export async function queryPet(type,content,page,limit){
    var resp = await axios.get("/api/petsSystem/pets.do",{
        params:{
            method:"query",
            type,
            content,
            page,
            limit
        }
    });
    return resp.data;
}